home *** CD-ROM | disk | FTP | other *** search
- ;MailRun v2.11: Part B, changesettings
- ;1992-1993 Gerald P. Sully, all rights reserved.
-
- #comment
- **************************************************************************
- **************************************************************************
- *
- * This file contains routines related to changing MailRun
- * settings. It puts up the MailRun Settings dialog box, and
- * writes any changes to the *.MRN file. If the user changes
- * the MailRun directory, it will move all MailRun Files to the
- * new directory and stop the script.
- *
- **************************************************************************
- **************************************************************************
- #endcomment
-
- #define MRUN211B
- #define MRUN211BC
- #define MRUN211AB
-
- #include "mrun211.h"
-
- #comment
- *********************************************************************
- *
- * MAIN()
- *
- * Calls checkchild(), checkdir(), settingsbox(), getfirstitem(),
- * loadsettings(), changemailrun(), makemailrunlist(),
- * menudim(), newmailrun(), interfaceon(), changemrundir(),
- * writesettings(), findstring(), checkchanged(),
- *
- * Allows the user to change the settings in the [MailRun]
- * section of the *.MRN file.
- *
- *********************************************************************
- #endcomment
-
- proc main
- string LastMRunDir, LastMailDir, LastReplyDir
- string LastDLDir, LastULDir, LastMRun
- integer dialogstatus
- menudim()
- checkchild()
- LastMRun = MailRun
- loadsettings(MailRun)
- LastMailDir = MailDir
- LastReplyDir = ReplyDir
- LastDLDir = DownloadDir
- LastULDir = UploadDir
- if FLAGS & DEFAULTS
- MailRunList = "mailrun.ini"
- MailRunTrunc = "mailrun.ini"
- LastMRunDir = MailRunDir
- else
- findfirst MailRun
- MailRunTrunc = $FILENAME
- makemailrunlist()
- endif
- FLAGS &= UNCHANGED
- settingsbox()
- if !(FLAGS & DEFAULTS)
- disable CTRL 242
- endif
- if LogRun == 0
- disable CTRL 71
- disable CTRL 72
- endif
- if FLAGS & RUNNING
- disable CTRL 170
- endif
- if FLAGS & NEW
- newmailrun()
- getfirstitem()
- LastMRun = MailRun
- endif
- interfaceon()
- while 1
- dialogstatus = $DIALOG
- switch dialogstatus
- case 10
- ;User selected "Save"
- ;if the directories chosen in settingsbox()
- ;don't exist, create them
- if checkdir(&MailRunDir, LastMRunDir) && \
- checkdir(&MailDir, LastMailDir) && \
- checkdir(&ReplyDir, LastReplyDir) && \
- checkdir(&DownloadDir, LastDLDir) && \
- checkdir(&UploadDir, LastULDir)
- ;if all directories were successfully created...
- chdir MailRunDir
- if FLAGS & DEFAULTS
- writesettings(MailRunIni)
- else
- writesettings(MailRun)
- endif
- else
- updatedlg 128
- endif
- FLAGS &= UNCHANGED
- endcase
- case 11
- ;User selected "Done"
- if checkchanged()
- ;if user has no unsaved changes...
- if (FLAGS & DEFAULTS) && !(findstring(LastMRunDir, MailRunDir))
- ;if user has changed the MailRun Directory
- changemrundir(LastMRunDir)
- updatedlg 128
- else
- exit
- endif
- endif
- endcase
- case 70
- ;User selected the Log MailRun checkbox
- if LogRun == 0
- ;If logging was turned off, disable the other checkboxes
- disable CTRL 71
- disable CTRL 72
- else
- ;Otherwise, enable the checkboxes
- enable CTRL 71
- enable CTRL 72
- endif
- FLAGS |= CHANGED
- updatedlg 1
- endcase
- case 170
- ;User changed mailrun with combobox
- if checkchanged()
- changemailrun()
- getfirstitem()
- LastMRun = MailRun
- updatedlg -1
- else
- findfirst MailRun
- MailRunTrunc = $FILENAME
- updatedlg 512
- endif
- endcase
- case 230
- case 231
- case 232
- case 233
- case 234
- case 235
- case 236
- case 237
- case 238
- case 239
- case 240
- case 241
- case 242
- case 71
- case 72
- case 73
- FLAGS |= CHANGED
- endcase
- endswitch
- endwhile
- endproc
-
-
- #comment
- *********************************************************************
- *
- * CHECKDIR()
- *
- * Called by main()
- *
- * Creates a directory. If the directory already exists or
- * was successfully created, a value of 0 is returned. If
- * an error occurs, the name of NewDir is changed to that
- * of OldDir, and a value of 1 is returned.
- *
- *********************************************************************
- #endcomment
-
- func checkdir : integer
- strparm NewDir, OldDir
- chdir NewDir
- if FAILURE
- mkdir NewDir
- if FAILURE
- usermsg "Unable to create directory %s" NewDir
- NewDir = OldDir
- return 0
- endif
- endif
- return 1
- endfunc
-
-
- #comment
- *********************************************************************
- *
- * NEWMAILRUN()
- *
- * Called by main()
- *
- * Calls fverify(), filesave(), makemrn(), makemailrunlist(),
- * makefullname()
- *
- * Prompts the user for the name of a new *.MRN file, checks
- * the name, and calls routines to create it.
- *
- *********************************************************************
- #endcomment
-
- proc newmailrun
- string NewRun, temp
- ;Make sure the entered MailRun ID is the correct length
- ;and that it doesn't already exist
- while 1
- NewRun = ""
- sdlginput "New MailRun" \
- "Enter the ID of the new mailrun:" NewRun
- if FAILURE
- exit
- endif
- strlwr NewRun
- if not fverify(NewRun)
- usermsg \
- "A mailrun ID must be a valid DOS file name without the extension."
- loopwhile
- endif
- strfmt temp "%s.mrn" NewRun
- NewRun = makefullname(MailRunDir, temp)
- if isfile NewRun
- errormsg "That MailRun already exists!"
- else
- exitwhile
- endif
- endwhile
-
- ;Update the previous mailrun
- filesave()
- delfile MailRun
- ;Create the new mailrun
- MailRunTrunc = temp
- makemrn()
- makemailrunlist()
- updatedlg -1
- endproc
-
-
- #comment
- *********************************************************************
- *
- * CHANGEMRUNDIR()
- *
- * Called by main()
- *
- * Calls movefiles(), fileexit(), makefullname()
- *
- * Requests confirmation, moves all MailRun support files
- * to the new MailRun Directory, and shuts down so that the
- * user can restart.
- *
- *********************************************************************
- #endcomment
-
- proc changemrundir
- strparm LastMRunDir
- string WarnMsg, CleanupFile
- integer Response
- strfmt WarnMsg "All MailRun files will be moved to`r`n`r`n\
- %s`r`n`r`nand MailRun will have to be restarted.`r`n`r`nDo you wish \
- continue?" MailRunDir
- sdlgmsgbox "MailRun Message" WarnMsg QUESTION YESNO Response 2
- switch Response
- case 6
- ;User selected "Yes"
- cleanupfile = makefullname(TempDir, "CLEANUP.TMP")
- profilerd cleanupfile "cleanup" "LastMRun" MailRun
- findfirst MailRun
- MailRunTrunc = $FILENAME
- profilewr MailRunIni "MailRun" "MailRunDir" MailRunDir
- movefiles(LastMRunDir, MailRunDir, "MRUN211?.WA?")
- movefiles(LastMRunDir, MailRunDir, "MRUN211.H")
- movefiles(LastMRunDir, MailRunDir, "NEWFILES.WA?")
- movefiles(LastMRunDir, MailRunDir, "TERMINAL.WA?")
- movefiles(LastMRunDir, MailRunDir, "*.MRN")
- movefiles(LastMRunDir, MailRunDir, "*.?DX")
- movefiles(LastMRunDir, MailRunDir, "*.?BF")
- movefiles(LastMRunDir, MailRunDir, "MRUNICON.DLL")
- movefiles(LastMRunDir, MailRunDir, "MAILRUN.WRI")
- fileexit()
- endcase
- case 7
- ;User selected "No"
- MailRunDir = LastMRunDir
- endcase
- endswitch
- endproc
-
-
- #comment
- *********************************************************************
- *
- * MOVEFILES()
- *
- * Called by changemrundir()
- *
- * Calls makefullname()
- *
- * Moves files matching the given filespec from their current
- * location to the MailRun directory.
- *
- *********************************************************************
- #endcomment
-
- proc movefiles
- strparm OldDir, NewDir, Spec
- string OldFile, NewFile, OldSpec
- OldSpec = makefullname(OldDir, Spec)
- findfirst OldSpec
- while FOUND
- if not strcmpi $FILENAME "MRUN211.WAS"
- if not strcmpi $FILENAME "MRUN211.WAX"
- statmsg "Moving %s" $FILENAME
- OldFile = makefullname(OldDir, $FILENAME)
- NewFile = makefullname(NewDir, $FILENAME)
- copyfile OldFile NewFile
- delfile OldFile
- endif
- endif
- findnext
- endwhile
- endproc
-
-
- #comment
- *********************************************************************
- *
- * SETTINGSBOX()
- *
- * Called by main()
- *
- * Displays the MailRun Settings dialog box.
- *
- *********************************************************************
- #endcomment
-
- proc settingsbox
- destroydlg
- HelpPage = 4
- dialogbox 15 36 340 222 15 "MailRun Settings" HELPID HelpPage
- groupbox 10 28 200 96 "Directories" shadow
- text 16 42 71 8 right "MailRun Directory:"
- text 16 58 71 8 right "Mail Directory:"
- text 16 74 71 8 right "Reply Directory:"
- text 16 90 71 8 right "Download Directory:"
- text 16 106 71 8 right "Upload Directory:"
- editbox 91 56 110 12 MailDir
- editbox 91 72 110 12 ReplyDir
- editbox 91 88 110 12 DownloadDir
- editbox 91 104 110 12 UploadDir
- groupbox 224 28 102 96 "Parameters" shadow
- text 234 42 62 8 right "Dial Attempts:"
- text 234 58 62 8 right "Dial Timeout:"
- text 234 74 62 8 right "Dial Pause:"
- text 234 90 62 8 right "Idle Timeout:"
- text 234 106 62 8 right "Packets to Save:"
- editbox 300 40 16 12 DialAttempts
- editbox 300 56 16 12 DialTimeout
- editbox 300 72 16 12 DialPause
- editbox 300 88 16 12 IdleTime
- editbox 300 104 16 12 SavePackets
- groupbox 10 132 124 59 "Logging" shadow
- checkbox 18 144 112 12 "Capture mailrun to log file" LogRun
- checkbox 18 158 112 12 "Append to existing log file" AppendLog
- checkbox 18 172 112 12 "Capture ANSI codes in log file" AnsiInLog
- checkbox 18 200 134 12 "Filter duplicates from d/l database" NewfileFilter
- groupbox 144 132 184 59 "Utilities" shadow
- text 145 146 65 8 right "Archive Utility:"
- text 145 160 65 8 right "QWK Mail Reader:"
- text 145 174 65 8 right "Log File Viewer:"
- editbox 214 144 107 12 Archiver
- editbox 214 158 107 12 QWKReader
- editbox 214 172 107 12 LogViewer
- pushbutton 191 200 40 14 "&Save" normal default
- pushbutton 252 200 40 14 "&Done" normal
- text 100 11 52 8 right "Settings for:"
- combobox 156 9 72 42 MailRunList MailRunTrunc sort
- editbox 91 40 110 12 MailRunDir
- enddialog
- endproc
-
-
-
-